package com.wclass.controller.app;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.wclass.common.GeTuiUtil;
import com.wclass.common.ReturnObject;
import com.wclass.entity.*;
import com.wclass.interceptor.BaseContextHandler;
import com.wclass.interceptor.IgnoreAuth;
import com.wclass.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * <p>
 * 帖子 前端控制器
 * </p>
 *
 * @author SEN
 * @since 2018-12-27
 */
@Api(description = "发现(帖子)管理")
@RestController
@RequestMapping("/postsInfo")
public class PostsInfoController {
    @Autowired
    private IPostsInfoService iPostsInfoService;
    @Autowired
    private IPostsReplyService iPostsReplyService;
    @Autowired
    private IPostsLikeService iPostsLikeService;
    @Autowired
    private IBaseCollectService iBaseCollectService;
    @Autowired
    private IBaseFocusService iBaseFocusService;
    @Autowired
    private IPostsSearchWordService iPostsSearchWordService;
    @Autowired
    private IBaseFeedbackService iBaseFeedbackService;
    @Autowired
    private IBaseAppUserService iBaseAppUserService;

    @ApiOperation("新增发现/帖子")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ReturnObject<PostsInfo> add(@ApiParam("标题") @RequestParam String title,
                                       @ApiParam("提交状态（1：审核中，3：已保存）") @RequestParam Integer submitState,
                                       @ApiParam("内容") @RequestParam String content,
                                       @ApiParam("多图附件") @RequestParam String attachmentUrl,
                                       @ApiParam("归属id") @RequestParam Long courseTypeId,
                                       @ApiParam("封面") String cover,
                                       @ApiParam("附件") String files) {
        PostsInfo postsInfo = new PostsInfo(0, submitState, title, content, attachmentUrl, 0, 0, 0,
                BaseContextHandler.getUserID(), 0, null, null, null, null, null, null, courseTypeId, null, null, null, cover, files);
        iPostsInfoService.insert(postsInfo);
        return new ReturnObject<>(0, "发布成功", postsInfo);
    }

    @ApiOperation("编辑发现/帖子")
    @RequestMapping(value = "/updataPostInfo", method = RequestMethod.POST)
    public ReturnObject<PostsInfo> updataPostInfo(@ApiParam("id") @RequestParam Long postId,
                                                  @ApiParam("标题") String title,
                                                  @ApiParam("提交状态（1：审核中，3：已保存）") Integer submitState,
                                                  @ApiParam("内容") String content,
                                                  @ApiParam("附件") String attachmentUrl,
                                                  @ApiParam("归属id") Long courseTypeId,
                                                  @ApiParam("封面") String cover,
                                                  @ApiParam("附件") String files) {
        PostsInfo postsInfo = iPostsInfoService.selectById(postId);
        if (postsInfo != null) {
            postsInfo.setTitle(title);
            postsInfo.setSubmitState(submitState);
            postsInfo.setContent(content);
            postsInfo.setAttachmentUrl(attachmentUrl);
            postsInfo.setCourseTypeId(courseTypeId);
            postsInfo.setCover(cover);
            postsInfo.setFiles(files);
            iPostsInfoService.updateById(postsInfo);
        }
        return new ReturnObject<>(0, "更新成功");
    }

    @ApiOperation("删除发现/帖子")
    @RequestMapping(value = "/delPostsInfo", method = RequestMethod.POST)
    public ReturnObject delPostsInfo(@ApiParam("id") @RequestParam Long postId){
        iPostsInfoService.deleteById(postId);
        return new ReturnObject(0, "删除成功");
    }

    @IgnoreAuth
    @ApiOperation("获取搜索历史和热门搜索")
    @RequestMapping(value = "/getPostsWordList", method = RequestMethod.POST)
    public ReturnObject<Object> getPostsWordList(@ApiParam("用户id") Long userId) {

        Map<String, Object> map = Maps.newHashMap();
        if (userId != null) {
            Page<PostsSearchWord> obj = iPostsSearchWordService.selectPage(new Page<>(
                    1, 10), new EntityWrapper<PostsSearchWord>().eq("user_id", userId).orderBy("crt_time", false));
            map.put("historyWords", obj.getRecords());
        } else {
            map.put("historyWords", null);
        }
        Page<PostsSearchWord> obj_hot = iPostsSearchWordService.getHotPostsSearch(new Page<>(1, 10));
        map.put("hotWords", obj_hot.getRecords());
        return new ReturnObject<>(0, "获取成功", map);
    }

    /**
     * 获取帖子分页
     *
     * @param limit
     * @param offset
     * @return
     */
    @IgnoreAuth
    @ApiOperation("获取发现分页")
    @RequestMapping(value = "/getPostsPage", method = RequestMethod.POST)
    public ReturnObject<List<PostsInfo>> getPostsPage(@ApiParam("每页条数") @RequestParam(defaultValue = "10") int limit,
                                                      @ApiParam("页数") @RequestParam(defaultValue = "1") int offset,
                                                      @ApiParam("1 推荐 2 关注") @RequestParam(defaultValue = "1") Integer type,
                                                      @ApiParam("模糊查询名称") String name) {
        EntityWrapper<PostsInfo> ew = new EntityWrapper<PostsInfo>();
        ew.eq("submit_state", 0);
        if (name != null && !name.isEmpty()) {
            ew.like("title", name);

            if (BaseContextHandler.getUserID() != null) {
                EntityWrapper<PostsSearchWord> ew_hotword = new EntityWrapper<>();
                ew_hotword.eq("word", name);
                List<PostsSearchWord> list = iPostsSearchWordService.selectList(ew_hotword);
                if (list == null || list.size() == 0) {
                    PostsSearchWord word = new PostsSearchWord();
                    word.setCount(1);
                    word.setCrtTime(new Date());
                    word.setUserId(BaseContextHandler.getUserID());
                    word.setWord(name);
                    iPostsSearchWordService.insert(word);
                } else {
                    PostsSearchWord word = list.get(0);
                    word.setCount(word.getCount() + 1);
                    iPostsSearchWordService.updateById(word);
                }
            }
        }
        ew.orderBy("info.crt_time", false);
        if (type == 2) {
            if (BaseContextHandler.getUserID() == null) {
                return new ReturnObject<>(401, "请先登录");
            }
            EntityWrapper<BaseFocus> ew_focus = new EntityWrapper<>();
            ew_focus.eq("user_id", BaseContextHandler.getUserID());
            List<BaseFocus> list = iBaseFocusService.selectList(ew_focus);
            List<Long> userIds = Lists.newArrayList();
            for (BaseFocus info : list) {
                userIds.add(info.getFocusUserId());
            }
            ew.in("info.user_id", userIds);
        }
        Page<PostsInfo> obj = iPostsInfoService.selectPage(new Page<>(offset, limit), ew);
        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

    /**
     * 获取我的发现分页
     *
     * @param limit
     * @param offset
     * @return
     */
    @ApiOperation("获取我的发现分页")
    @RequestMapping(value = "/getMyPostsPage", method = RequestMethod.POST)
    public ReturnObject<List<PostsInfo>> getMyPostsPage(@ApiParam("每页条数") @RequestParam(defaultValue = "10") int limit,
                                                        @ApiParam("页数") @RequestParam(defaultValue = "1") int offset,
                                                        @ApiParam("提交状态（0：已通过，1：审核中，2：未通过，3：已保存）") Integer submitState) {

        EntityWrapper<PostsInfo> ew = new EntityWrapper<PostsInfo>();
        ew.eq("user_id", BaseContextHandler.getUserID());
        ew.orderBy("info.crt_time", false);
        if (submitState != null) {
            ew.eq("info.submit_state", submitState);
        }

        Page<PostsInfo> obj = iPostsInfoService.selectPage(new Page<>(offset, limit), ew);

        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

    /**
     * 获取指定用户的发现分页
     *
     * @param limit
     * @param offset
     * @return
     */
    @ApiOperation("获取指定用户的发现分页")
    @RequestMapping(value = "/getMyPostsPageByUserId", method = RequestMethod.POST)
    public ReturnObject<List<PostsInfo>> getMyPostsPageByUserId(@ApiParam("每页条数") @RequestParam(defaultValue = "10") int limit,
                                                                @ApiParam("页数") @RequestParam(defaultValue = "1") int offset,
                                                                @ApiParam("用户id") @RequestParam Long userId) {

        EntityWrapper<PostsInfo> ew = new EntityWrapper<PostsInfo>();
        ew.eq("info.submit_state", 0);
        ew.eq("info.user_id", userId);
        ew.orderBy("info.crt_time", false);
        Page<PostsInfo> obj = iPostsInfoService.selectPage(new Page<>(offset, limit), ew);
        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

    /**
     * 查看帖子
     *
     * @param id
     * @return
     */
    @IgnoreAuth
    @ApiOperation("获取帖子详情")
    @RequestMapping(value = "/getInfo", method = RequestMethod.POST)
    public ReturnObject<PostsInfo> getInfo(@ApiParam("id") @RequestParam Long id) {
        PostsInfo postsInfo = iPostsInfoService.selectById(id);

        if (BaseContextHandler.getUserID() != null) {
            postsInfo.setType(iBaseAppUserService.selectOneById(postsInfo.getUserId()).getType());

            //获取是否点赞
            EntityWrapper ew_like = new EntityWrapper<PostsLike>();
            ew_like.eq("info.user_id", BaseContextHandler.getUserID()).eq("info.posts_id", id);
            Integer count = iPostsLikeService.selectCount(ew_like);
            if (count > 0) {
                postsInfo.setWhetherLike(1);
            } else {
                postsInfo.setWhetherLike(0);
            }

            //获取是否收藏
            EntityWrapper<BaseCollect> ew_collect = new EntityWrapper<BaseCollect>();
            ew_collect.eq("user_id",
                    BaseContextHandler.getUserID()).eq("mold_id", id).eq("type", 1);
            Integer count_colloect = iBaseCollectService.selectCount(ew_collect);
            if (count_colloect > 0) {
                postsInfo.setWhetherCollect(1);
            } else {
                postsInfo.setWhetherCollect(0);
            }

            //获取是否关注
            EntityWrapper<BaseFocus> ew_focus = new EntityWrapper<BaseFocus>();
            ew_focus.eq("user_id", BaseContextHandler.getUserID());
            ew_focus.eq("focus_user_id", postsInfo.getUserId());
            Integer count_focus = iBaseFocusService.selectCount(ew_focus);
            if (count_focus > 0) {
                postsInfo.setWhetherFocus(1);
            } else {
                postsInfo.setWhetherFocus(0);
            }
        }

        return new ReturnObject<>(0, "获取成功", postsInfo);
    }

    @ApiOperation("举报帖子")
    @RequestMapping(value = "/reportPosts", method = RequestMethod.POST)
    public ReturnObject reportPosts(@ApiParam("帖子id") @RequestParam Long id,
                                    @ApiParam("举报内容") @RequestParam String content){
        //插入举报记录
        BaseFeedback feedback = new BaseFeedback();
        feedback.setCrtTime(new Date());
        feedback.setState(0);
        feedback.setContent(content);
        feedback.setPhone(iBaseAppUserService.selectById(BaseContextHandler.getUserID()).getPhone());
        feedback.setType(3);
        feedback.setReportId(id);
        feedback.setUserId(BaseContextHandler.getUserID());
        iBaseFeedbackService.insert(feedback);
        return new ReturnObject(0, "操作成功");
    }

    /**
     * 获取帖子评论分页
     *
     * @param limit
     * @param offset
     * @return
     */
    @ApiOperation("web--获取发现评论分页")
    @RequestMapping(value = "/getPostsReplyPage", method = RequestMethod.POST)
    public ReturnObject<List<PostsReply>> getPostsReplyPage(@ApiParam("每页条数") @RequestParam(defaultValue = "10") int limit,
                                                            @ApiParam("页数") @RequestParam(defaultValue = "1") int offset,
                                                            @ApiParam("帖子id") @RequestParam Long id,
                                                            @ApiParam("已读未读状态 0 未读 1 已读") Integer isNew) throws Exception {
        EntityWrapper<PostsReply> ew = new EntityWrapper<>();
        ew.orderBy("info.crt_time", false).eq("posts_id", id).isNull("p_id");
        if (isNew != null) {
            ew.eq("info.is_new", isNew);
        }
        Page<PostsReply> obj = iPostsReplyService.selectPage(new Page<>(offset, limit), ew);

        //获取帖子评论的子评论列表
        for (PostsReply postsReply : obj.getRecords()) {
            //进行解码
            postsReply.setContent(new String(Base64.getDecoder().decode(postsReply.getContent().getBytes()),"utf-8"));

            List<PostsReply> childList = Lists.newArrayList();
            foreachGetChildReply(childList, postsReply, id, 1, 5);
            //对子评论按时间进行倒序排序
            Collections.sort(childList, new SortByCrtTime());
            postsReply.setChildReplyList(childList);
        }

        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

    /**
     * 获取帖子评论分页
     *
     * @param limit
     * @param offset
     * @return
     */
    @ApiOperation("mobile--获取发现评论分页")
    @RequestMapping(value = "/getMobilePostsReplyPage", method = RequestMethod.POST)
    public ReturnObject<List<PostsReply>> getMobilePostsReplyPage(@ApiParam("每页条数") @RequestParam(defaultValue = "10") int limit,
                                                                  @ApiParam("页数") @RequestParam(defaultValue = "1") int offset,
                                                                  @ApiParam("帖子id") @RequestParam Long id,
                                                                  @ApiParam("已读未读状态 0 未读 1 已读") Integer isNew) throws Exception {
        EntityWrapper<PostsReply> ew = new EntityWrapper<>();
        ew.orderBy("info.crt_time", false).eq("posts_id", id);
        if (isNew != null) {
            ew.eq("info.is_new", isNew);
        }
        Page<PostsReply> obj = iPostsReplyService.selectPage(new Page<>(offset, limit), ew);

        //获取帖子评论的父评论信息
        for (PostsReply postsReply : obj.getRecords()) {
            //进行解码
            postsReply.setContent(new String(Base64.getDecoder().decode(postsReply.getContent().getBytes()),"utf-8"));

            if (postsReply.getPId() != null) {
                List<PostsReply> childList = Lists.newArrayList();
                PostsReply reply = iPostsReplyService.selectById(postsReply.getPId());
                //进行解码
                reply.setContent(new String(Base64.getDecoder().decode(reply.getContent().getBytes()),"utf-8"));

                BaseAppUser user = iBaseAppUserService.selectById(reply.getUserId());
                reply.setNickName(user.getNickName());
                reply.setPictureAddress(user.getPictureAddress());
                childList.add(reply);
                postsReply.setChildReplyList(childList);
            }
        }

        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

    class SortByCrtTime implements Comparator {
        public int compare(Object obj1, Object obj2) {
            PostsReply reply_1 = (PostsReply) obj1;
            PostsReply reply_2 = (PostsReply) obj2;
            if (reply_1.getCrtTime().getTime() > reply_2.getCrtTime().getTime())
                return -1;
            return 1;
        }
    }

    /**
     * 获取帖子评论的子评论列表
     */
    public void foreachGetChildReply(List<PostsReply> childList, PostsReply postsReply, Long postsId, Integer page, Integer limit) throws Exception {
        EntityWrapper<PostsReply> ew = new EntityWrapper<>();
        ew.orderBy("crt_time", false).eq("posts_id", postsId).eq("p_id", postsReply.getId());
        List<PostsReply> list;
        if (page != null && limit != null) {
            Page<PostsReply> obj = iPostsReplyService.selectPage(new Page<>(page, limit), ew);
            list = obj.getRecords();
        } else {
            list = iPostsReplyService.selectList(ew);
        }
        for (PostsReply childReply : list) {
            //进行解码
            childReply.setContent(new String(Base64.getDecoder().decode(childReply.getContent().getBytes()),"utf-8"));

            childList.add(childReply);
            foreachGetChildReply(childList, childReply, postsId, page, limit);
        }
    }

    @ApiOperation("新增帖子评论")
    @RequestMapping(value = "/addReply", method = RequestMethod.POST)
    public ReturnObject<PostsReply> addReply(@ApiParam("帖子id") @RequestParam Long id,
                                             @ApiParam("内容") @RequestParam String content) throws Exception {
        //进行编码
        content = new String(Base64.getEncoder().encode(content.getBytes()));
        PostsReply postsReply = new PostsReply(0, content, BaseContextHandler.getUserID(), null, id, null, null, 0, null, null, null);
        iPostsReplyService.insert(postsReply);

        PostsInfo postsInfo = iPostsInfoService.selectById(id);
        BaseAppUser postIssuer = iBaseAppUserService.selectOneById(postsInfo.getUserId());
        String cid = "";
        if (postIssuer.getMobileType() != null && postIssuer.getMobileType().equals("android")) {
            cid = postIssuer.getCId();
        } else if (postIssuer.getMobileType() != null && postIssuer.getMobileType().equals("ios")) {
            cid = postIssuer.getDeviceToken();
        }
        if (cid.length() > 0)
            GeTuiUtil.pushMessageToSingle(postIssuer.getMobileType(), cid, "你有一条新的评论。");
        return new ReturnObject<>(0, "发布成功", postsReply);
    }

    @ApiOperation("新增评论的评论")
    @RequestMapping(value = "/addReplyReply", method = RequestMethod.POST)
    public ReturnObject<PostsReply> addReplyReply(@ApiParam("评论id") @RequestParam Long id,
                                                  @ApiParam("内容") @RequestParam String content) throws Exception {
        PostsReply old = iPostsReplyService.selectById(id);
        //进行编码
        content = new String(Base64.getEncoder().encode(content.getBytes()));
        PostsReply postsReply = new PostsReply(0, content, BaseContextHandler.getUserID(), id, old.getPostsId(), null, null, 0, null, null, null);
        iPostsReplyService.insert(postsReply);

        BaseAppUser oldIssuer = iBaseAppUserService.selectOneById(old.getUserId());
        String cid = "";
        if (oldIssuer.getMobileType() != null && oldIssuer.getMobileType().equals("android")) {
            cid = oldIssuer.getCId();
        } else if (oldIssuer.getMobileType() != null && oldIssuer.getMobileType().equals("ios")) {
            cid = oldIssuer.getDeviceToken();
        }
        if (cid.length() > 0)
            GeTuiUtil.pushMessageToSingle(oldIssuer.getMobileType(), cid, "你有一条新的评论。");
        return new ReturnObject<>(0, "发布成功", postsReply);
    }

    @ApiOperation("删除评论")
    @RequestMapping(value = "/delPostsReply", method = RequestMethod.POST)
    public ReturnObject delPostsReply(@ApiParam("评论id") @RequestParam Long id) throws Exception {
        PostsReply postsReply = iPostsReplyService.selectById(id);
        List<PostsReply> childList = Lists.newArrayList();
        foreachGetChildReply(childList, postsReply, postsReply.getPostsId(), null, null);

        List<Long> replyIds = Lists.newArrayList();
        replyIds.add(id);
        for (PostsReply reply : childList) {
            replyIds.add(reply.getId());
        }
        iPostsReplyService.deleteBatchIds(replyIds);

        return new ReturnObject<>(0, "删除评论成功");
    }

    @ApiOperation("帖子点赞或者取消点赞")
    @RequestMapping(value = "/like", method = RequestMethod.POST)
    public ReturnObject like(@ApiParam("帖子id") @RequestParam Long id) throws Exception {
        if (iPostsLikeService.selectCount(new EntityWrapper<PostsLike>().eq("info.user_id",
                BaseContextHandler.getUserID()).eq("info.posts_id", id)) > 0) {
            //取消点赞
            iPostsLikeService.delete(new EntityWrapper<PostsLike>().eq("user_id",
                    BaseContextHandler.getUserID()).eq("posts_id", id));
            return new ReturnObject<>(0, "取消成功");
        } else {
            //点赞
            iPostsLikeService.insert(new PostsLike(BaseContextHandler.getUserID(), id, null, 0, null, null, null, null));

            PostsInfo postsInfo = iPostsInfoService.selectById(id);
            BaseAppUser postIssuer = iBaseAppUserService.selectOneById(postsInfo.getUserId());
            String cid = "";
            if (postIssuer.getMobileType() != null && postIssuer.getMobileType().equals("android")) {
                cid = postIssuer.getCId();
            } else if (postIssuer.getMobileType() != null && postIssuer.getMobileType().equals("ios")) {
                cid = postIssuer.getDeviceToken();
            }
            if (cid.length() > 0)
                GeTuiUtil.pushMessageToSingle(postIssuer.getMobileType(), cid, "你的帖子被点赞啦。");
            return new ReturnObject<>(0, "点赞成功");
        }
    }

    @ApiOperation("获取未读评论分页")
    @RequestMapping(value = "/getUnreadPostsReplyList", method = RequestMethod.POST)
    public ReturnObject<List<PostsReply>> getUnreadPostsReplyList(@ApiParam("每页条数") @RequestParam(defaultValue = "10") int limit,
                                                                  @ApiParam("页数") @RequestParam(defaultValue = "1") int offset) throws Exception {
        Page<PostsReply> obj = iPostsReplyService.selectUnreadPostsReplyPage(new Page<>(offset, limit), BaseContextHandler.getUserID());
        List<PostsReply> list = Lists.newArrayList();
        for (PostsReply postsReply : obj.getRecords()) {
            //进行解码
            postsReply.setContent(new String(Base64.getDecoder().decode(postsReply.getContent().getBytes()),"utf-8"));
            postsReply.setBeCommentName(BaseContextHandler.getName());
            postsReply.setIsNew(1);

            PostsReply record = new PostsReply();
            record.setId(postsReply.getId());
            record.setIsNew(1);
            list.add(record);

            if (postsReply.getPId() != null) {
                PostsReply reply = iPostsReplyService.selectById(postsReply.getPId());
                //进行解码
                reply.setContent(new String(Base64.getDecoder().decode(reply.getContent().getBytes()),"utf-8"));
                if (reply.getUserId().equals(BaseContextHandler.getUserID())){
                    postsReply.setBeCommentContent(reply.getContent());
                }
            }
            if (StringUtils.isBlank(postsReply.getBeCommentContent())) {
                PostsInfo postsInfo = iPostsInfoService.selectContainDelRecord(postsReply.getPostsId());
                if (postsInfo.getUserId().equals(BaseContextHandler.getUserID())) {
                    postsReply.setBeCommentContent(postsInfo.getTitle());
                }
            }
        }
        if (list.size() > 0)
            iPostsReplyService.updateBatchById(list);

        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

    @ApiOperation("获取未读点赞分页")
    @RequestMapping(value = "/getUnreadPostsLikeList", method = RequestMethod.POST)
    public ReturnObject<List<PostsLike>> getUnreadPostsLikeList(@ApiParam("每页条数") @RequestParam(defaultValue = "10") int limit,
                                                                @ApiParam("页数") @RequestParam(defaultValue = "1") int offset) throws Exception {
        Page<PostsLike> obj = iPostsLikeService.selectUnreadPostsLikePage(new Page<>(offset, limit), BaseContextHandler.getUserID());
        List<PostsLike> list = Lists.newArrayList();
        for (PostsLike postsLike : obj.getRecords()) {
            postsLike.setBeCommentName(BaseContextHandler.getName());
            postsLike.setIsNew(1);
            list.add(postsLike);

            if (postsLike.getReplyId() != null) {
                PostsReply reply = iPostsReplyService.selectById(postsLike.getReplyId());
                //进行解码
                reply.setContent(new String(Base64.getDecoder().decode(reply.getContent().getBytes()),"utf-8"));
                if (reply.getUserId().equals(BaseContextHandler.getUserID())){
                    postsLike.setBeCommentContent(reply.getContent());
                }
            }
            if (postsLike.getPostsId() != null) {
                PostsInfo postsInfo = iPostsInfoService.selectById(postsLike.getPostsId());
                if (postsInfo.getUserId().equals(BaseContextHandler.getUserID())) {
                    postsLike.setBeCommentContent(postsInfo.getTitle());
                }
            }
        }
        if (list.size() > 0)
            iPostsLikeService.updateBatchById(list);

        return new ReturnObject<>(0, "获取成功", obj.getTotal(), obj.getPages(), obj.getRecords());
    }

}

